package com.pxmeta.common.utils;

import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

/**
 * 机器人工具类
 *
 * @author <achao1441470436@gmail.com>
 * @since 2022/4/6 22:04
 */
public class RobotUtils {
	private static final Log log = LogFactory.get();

	public static void main(String[] args) {
		sendMsgToFeiShu("测试飞书机器人🤖");
	}

	/**
	 * 测试飞书机器人
	 *
	 * @param content 发送内容
	 */
	public static void sendMsgToFeiShu(String content) {
		HttpResponse response = HttpUtil.createPost("https://open.feishu.cn/open-apis/bot/v2/hook/efa28886-f378-4f3a-aaff-fa494f837516").header("Content-Type", "application/json").body(JSONUtil.toJsonStr(MapBuilder.create().put("msg_type", "text").put("content", MapUtil.of("text", content)).build())).execute();
		log.debug(response.body());
	}

}
